import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.StringTokenizer;

public class TestDemo {
    public static void main(String[] args)  {
        try (InputStream inputStream = new FileInputStream("in.dat");
        OutputStream outputStream = new FileOutputStream("out.dat")) {

            byte[] bytes = new byte[1024];
            int len = inputStream.read(bytes);

            String s = new String(bytes, 0, len);
            StringTokenizer stringTokenizer = new StringTokenizer(s, ",");

            len = stringTokenizer.countTokens();
            String[] strings = new String[len];
            for (int i = 0; i < len; i++) {
                strings[i] = stringTokenizer.nextToken();
            }
            Arrays.sort(strings);

            StringBuffer stringBuffer = new StringBuffer();
            for (int i = 0; i < len; i++) {
                stringBuffer.append(strings[i]);
                if (i < len - 1) stringBuffer.append(",");
            }

            s = stringBuffer.toString();
            outputStream.write(s.getBytes());

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
